/******************************************************文本框*****************************************************/
_$.Text=function (target){
    var _this = this;
    _$.Text.superclass.constructor.call(_this,target);
};
_$.regClass("Text",_$.Text);

_$.extend(_$.Text,_$.FormItem, {
    _cls:_$._clsPre + "Text",
    _uiCls:_$._uiPreCls + "Text",
    _attrProps:function(){
        var _this = this;
        var properties = _$.Text.superclass._attrProps.call(_this);
        properties.addAll(["onfocus","oninput","onblur","onchange","inputStyle"]);
        return properties;
    },
    _attrOpts:function(){
        var _this = this;
        var opts = _$.Text.superclass._attrOpts.call(_this);
        return $.extend(true,opts,{
            type:"text"
        });
    },
    _editModel:function(){
        var _this = this;
        _this._clearShow();
        var source='<input type="{{type}}" class="Text" />';
        _this._replaceNode(source);
        _this.component = $(".Text",_this.el);
        _this.el.addClass(_this._uiCls);
        _this._setStyle();
        _this.setOption("model",_EDITABLE_);
        _this._init();
        _this._bindEvents();
    },
    _bindEvents:function(){
        var _this = this;
        _$.Text.superclass._getEvents.call(_this, ["onfocus","oninput","onblur","onchange"]);
        if(_this._isEdit()){
            var event = {
                "name":_this.id
            };

            _this.component.bind("focus",function(e){
                event['source'] = _this.component;
                event['value'] = _this.getValue();
                _this._focusHandler(event);
            });
            _this.component.bind("input propertychange",function(){
                event['source'] = _this.component;
                event['value'] = _this.getValue();
                _this._inputHandler(event);
            });
            _this.component.bind("blur",function(){
                event['source'] = _this.component;
                event['value'] = _this.getValue();
                _this._blurHandler(event);
            });
        }
    },
    _blurHandler:function(event){
        var _this = this;
        _this._fire("onblur",event);
        var original = isNotEmpty(_this.original)?_this.original:_this.getOption("initValue");
        var value = _this.getValue();
        if(original != value){
            _this.original=value;
            _this._fire("onchange",event);
        }
    },
    _inputHandler:function(event){
        var _this = this;
        _this._fire("oninput",event)
    },
    _focusHandler:function(event){
        var _this = this;
       _this._fire("onfocus",event)
   },
    _setStyle:function(){
        var _this = this;
        var width = _this.getOption('width');
        if(isNotEmpty(width)){
            _this.component.css({
                "width":width + "px"
            });
        }
        var height =_this.getOption('height');
        if(isNotEmpty(height)){
            _this.component.css({
                "height":height + "px"
            });
        }
        var inputStyle = _this.getOption('inputStyle');
        if(isNotEmpty(inputStyle)){
            _$.css(_this.component,inputStyle)
        }
    }
});
